package 寒假刷题;

public class 七进制数 {
    public String convertToBase7(int num) {
        StringBuilder builder = new StringBuilder();
        if (num==0)
            return "0";
        boolean flag = num<0;
        num = Math.abs(num);
        while (num>0){
            builder.append(num%7);
            num/=7;
        }
        if (flag)
            builder.append("-");
        return builder.reverse().toString();
    }
}
